import { Video } from '@/models/index'

// const videos: Video[] = [
//     {
//         id: 1,
//         name: "小约翰可汗是什么耗子？",
//         pic: "http://i1.hdslb.com/bfs/archive/e281360e6d36e645dbc1146cb9e7027fbf80f917.jpg",
//     },
//     {
//         id: 2,
//         name: "小约翰可汗是什么耗子？",
//         pic: "http://i1.hdslb.com/bfs/archive/e281360e6d36e645dbc1146cb9e7027fbf80f917.jpg",
//     },
//     {
//         id: 3,
//         name: "小约翰可汗是什么耗子？",
//         pic: "http://i1.hdslb.com/bfs/archive/e281360e6d36e645dbc1146cb9e7027fbf80f917.jpg",
//     },
// ]

export const getVideosRequest = (): Promise<Video[]> => {
    const p = new Promise<Video[]>((resolve, reject) => {
        // setTimeout(() => {
        //     resolve(videos)
        // }, 1000)
        fetch('http://localhost:3300/getvideos')
            .then(data => data.json())
            .then(data => {
                resolve(data);
            })
    });
    return p;
}

export const getHotwordRequest = (): Promise<any[]> => {
    const p = new Promise<Video[]>((resolve, reject) => {
        fetch('http://localhost:3300/search/hotword')
            .then(data => data.json())
            .then(data => {
                resolve(data)
            })
    })
    return p;
}
